home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: novice.uwaterloo.ca!a2patel
- From: a2patel@novice.uwaterloo.ca (Aashish-Kaski-Ashman-Patel)
- Subject: Newbie Ques: Templates and C++
- Sender: news@novice.uwaterloo.ca (Mr. News)
- Message-ID: <DoqLy6.H7q@novice.uwaterloo.ca>
- Date: Sat, 23 Mar 1996 20:22:54 GMT
- Nntp-Posting-Host: novice.uwaterloo.ca
- Organization: University of Waterloo
-
- Ok.. Here is what I am trying to do:
- 1)
- Have a class called Dictionary that depends on two other classes ( determined
- at compile time ).
- ie. #ifdef HASH
- class Dictionary Hash-Table;
- #else-if BST
- class Dictionary Bst;
- #endif
-
- Now Hashtable is a template class .. defined
- template <class typeofwhatever>
- class HashTable
- {
- //whatever;
- }
- The class definitions are in a header file, and the code in a normal source
- file. The problem is that when I try to compile the source, I get errors.
- I believe that this is just a syntax probelm.. The error I get is
- HashTable::HashTable() cannot be defined in the same scope as class template.
-
- Furthermore, are the ifdefs above correct... and can I have the following
- statement..
- class Dictionary HashTable<int>;
- I have tried these and have gotten errors... I do believe that this is possible
- but I don't have the syntax correct..
-
- any help is appreciated..
- Thanx.
-
- --
- ------------------- Aashish Patel. ---------------
- Electrical Engineering, Univesity Of Waterloo.
- mailto: a2patel@novice.uwaterloo.ca
- http://www.io.org/~cyourth/aashish.htm (old)
-